package com.paradise.ytj.utils;

import android.content.Context;

import com.paradise.ytj.bean.Constant;

/**
 * Created by Administrator on 2017/11/2 0002.
 */

public class SpUtils {

    public static String getString(Context context, String key, String defValue) {
        return context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE).getString(key, defValue);
    }

    public static int getInt(Context context, String key, int defValue) {
        return context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE).getInt(key, defValue);
    }

    public static boolean getBoolean(Context context, String key, boolean defValue) {
        return context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE).getBoolean(key, defValue);
    }

    public static void putString(Context context, String key, String defValue) {
        context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE)
                .edit()
                .putString(key, defValue)
                .apply();
    }

    public static void putInt(Context context, String key, int defValue) {
        context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE)
                .edit()
                .putInt(key, defValue)
                .commit();
    }

    public static void putBoolean(Context context, String key, boolean defValue) {
        context.getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE)
                .edit()
                .putBoolean(key, defValue)
                .commit();
    }

}
